package entity.sparemanage.dto;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import entity.sparemanage.SpareLedger;

/* *
 * @Author: beisheng
 * @Descriprion: 备件台账QueryWrapper条件判断
 * @Date: 2023/5/19 9:13
 */

public class SpareQueryWrapperDto {
    public QueryWrapper<SpareLedger> determine(SpareLedger spareLedger){
        QueryWrapper<SpareLedger> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("delete_flag",0);
        if (spareLedger.getCodeName() != null){
            String codeName = spareLedger.getCodeName();
            queryWrapper.like("sp_code",codeName).or().like("sp_name",codeName);
        }
        if (spareLedger.getSpCode() != null){
            queryWrapper.like("sp_code",spareLedger.getSpCode());
        }
        if(spareLedger.getSpName() != null){
            queryWrapper.like("sp_name",spareLedger.getSpName());
        }
        if (spareLedger.getSpSpecification()!= null){
            queryWrapper.eq("sp_specification",spareLedger.getSpSpecification());
        }
        if (spareLedger.getSpTypeId()!=null){
            queryWrapper.eq("sp_type_id",spareLedger.getSpTypeId());
        }
        if (spareLedger.getFactureName() != null){
            queryWrapper.like("facture_name",spareLedger.getFactureName());
        }
        if (spareLedger.getTotalInventory()!=null){
            queryWrapper.eq("total_inventory",spareLedger.getTotalInventory());
        }
        if(spareLedger.getOperator() != null){
            queryWrapper.eq("operator",spareLedger.getOperator());
        }
        if(spareLedger.getUpdateTime()!=null){
            queryWrapper.like("update_time",spareLedger.getUpdateTime());
        }
        return queryWrapper;
    }
}
